package net.java.mediasystems.web.bean;

import java.io.Serializable;

import net.java.mediasystems.database.core.model.Genre;
import net.java.mediasystems.database.core.service.FindableWithNameAndMediaType;
import net.java.mediasystems.database.core.service.GenreService;

/**
 * AddGenreBean.
 */
public class AddGenreBean extends AbstractAddObjectWithNameAndMediaTypeBean implements Serializable {

	private static final long serialVersionUID = 8033622786986485537L;
	
	private transient GenreService genreService;
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	FindableWithNameAndMediaType<Genre> getFindableWithNameAndMediaType() {
		return this.genreService;
	}	
	
	/**
	 * Save the Genre.
	 */
	public void save() {
		Genre genre = new Genre();
		genre.setName(this.name);
		genre.setMediaType(this.type);
		
		this.genreService.addGenre(genre);
	}
	
	public void setGenreService(GenreService genreService) {
		this.genreService = genreService;
	}
}
